﻿Imports MTPServer
Imports MTPClient
Imports System.Net.Sockets
Imports System.Text
Imports System.IO
Imports System.Net
Public Class Form1
    Dim mysrv As MTPServerObj
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        mysrv = New MTPServerObj(IPAddress.Any, 5556)
    End Sub

    Private Sub Form1_Closing(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.FormClosing
        If (mysrv.initialized) Then
            mysrv.close()
        End If
        Environment.Exit(0)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If (RadioButton1.Checked) Then
            Dim initialized As Boolean = mysrv.initialize()
            If (initialized) Then
                mysrv.start()
                Button1.Enabled = False
            End If
        Else
            Dim transfer As New MTPTransfer(InputText.Text, 8, HostName.Text, 5556, OutputText.Text)
            transfer.start()
            While (Not transfer.finished)
            End While
            MsgBox("DONE!")
        End If
    End Sub
End Class
